package com.zhoug.demo.viewpermission.network;

import com.zhoug.viewpermission.NavigationMenu;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author: zhoug
 * @since: 2025-06-12
 */
public class PageMenu {
        private String Id;// 菜单id   "4974532795681499536",
        private String ParentId;//父菜单id    "4703271707361880298",
        private String Code;// 菜单编码   "/yplt/bookTab",
        private String Type;// 菜单等级  "2",
        private String Name;//  菜单名称  "台账监管",
        private String Description;//描述    "台账监管Tab首页",
        private String SelfUrl;//   组件路径 navigation  "/yplt/bookTab",
        private String Url;//   路由路径 navigation  "/yplt/bookTab",
        private String DefaultIcon;// 默认图标  icon "",
        private String SmallIcon;// 小图标   "",
        private String IconSet;//  图标样式名称  "",
        private int SortOrder;// 排序号   2,
        private boolean Visible;//  是否显示  true,
        private boolean IsDeleted;//  是否删除  false,
        private int MenuType;//   菜单类型（0：菜单，1：目录,2:按钮） 0,
        private int Status;//   状态（0：正常，1：停用）
        private String PermissionKey;//  权限标识  null,
        private String SId;// 系统id   "4669607444862532350",
        private String SystemCode;//    "S012_11",
        private String SystemName;//    "药械经营流通质量安全管理系统-监管App",

        private List<PageMenu> children;


        public String getId() {
            return Id;
        }

        public void setId(String id) {
            Id = id;
        }

        public String getParentId() {
            return ParentId;
        }

        public String getSelfUrl() {
            return SelfUrl;
        }

        public void setSelfUrl(String selfUrl) {
            SelfUrl = selfUrl;
        }

        public void setParentId(String parentId) {
            ParentId = parentId;
        }

        public String getCode() {
            return Code;
        }

        public void setCode(String code) {
            Code = code;
        }

        public String getType() {
            return Type;
        }

        public void setType(String type) {
            Type = type;
        }

        public String getName() {
            return Name;
        }

        public void setName(String name) {
            Name = name;
        }

        public String getDescription() {
            return Description;
        }

        public void setDescription(String description) {
            Description = description;
        }

        public String getUrl() {
            return Url;
        }

        public void setUrl(String url) {
            Url = url;
        }


        public String getDefaultIcon() {
            return DefaultIcon;
        }

        public void setDefaultIcon(String defaultIcon) {
            DefaultIcon = defaultIcon;
        }

        public String getSmallIcon() {
            return SmallIcon;
        }

        public void setSmallIcon(String smallIcon) {
            SmallIcon = smallIcon;
        }

        public String getIconSet() {
            return IconSet;
        }

        public void setIconSet(String iconSet) {
            IconSet = iconSet;
        }

        public int getSortOrder() {
            return SortOrder;
        }

        public void setSortOrder(int sortOrder) {
            SortOrder = sortOrder;
        }

        public boolean isVisible() {
            return Visible;
        }

        public void setVisible(boolean visible) {
            Visible = visible;
        }

        public boolean isDeleted() {
            return IsDeleted;
        }

        public void setDeleted(boolean deleted) {
            IsDeleted = deleted;
        }

        public int getMenuType() {
            return MenuType;
        }

        public void setMenuType(int menuType) {
            MenuType = menuType;
        }

        public int getStatus() {
            return Status;
        }

        public void setStatus(int status) {
            Status = status;
        }

        public String getPermissionKey() {
            return PermissionKey;
        }

        public void setPermissionKey(String permissionKey) {
            PermissionKey = permissionKey;
        }

        public String getSId() {
            return SId;
        }

        public void setSId(String SId) {
            this.SId = SId;
        }

        public String getSystemCode() {
            return SystemCode;
        }

        public void setSystemCode(String systemCode) {
            SystemCode = systemCode;
        }

        public String getSystemName() {
            return SystemName;
        }

        public void setSystemName(String systemName) {
            SystemName = systemName;
        }

        public List<PageMenu> getChildren() {
            return children;
        }

        public void setChildren(List<PageMenu> children) {
            this.children = children;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            PageMenu pageMenu = (PageMenu) o;
            return Objects.equals(Id, pageMenu.Id);
        }

        @Override
        public int hashCode() {
            return Objects.hash(Id);
        }


        public static List<NavigationMenu> toNavigationMenus(List<PageMenu> menus) {
            List<NavigationMenu> result=null;
            if (menus != null && !menus.isEmpty()) {
                result = new ArrayList<>();
                for (PageMenu item : menus) {
                    NavigationMenu navigationMenu = new NavigationMenu();
                    result.add(navigationMenu);
                    navigationMenu.setId(item.getId());
                    navigationMenu.setParentId(item.getParentId());
                    navigationMenu.setName(item.getName());
                    navigationMenu.setCode(item.getCode());
                    navigationMenu.setDescription(item.getDescription());
                    navigationMenu.setPath(item.getSelfUrl());
                    navigationMenu.setNavigation(item.getUrl());
                    navigationMenu.setIcon(item.getDefaultIcon());
                    navigationMenu.setSortOrder(item.getSortOrder());
                    navigationMenu.setVisible(item.isVisible());
                    navigationMenu.setDeleted(item.isDeleted());
                    navigationMenu.setMenuType(item.getMenuType());
                    navigationMenu.setStatus(item.getStatus());
                    navigationMenu.setPermissionKey(item.getPermissionKey());
                    navigationMenu.setSystemCode(item.getSystemCode());
                    navigationMenu.setSystemName(item.getSystemName());
                }
            }
            return result;
        }
}
